package com.imti.mall.sale.mapper;

import com.imti.mall.model.sms.pojo.SmsFlashPromotionLog;
import org.apache.ibatis.jdbc.SQL;

public class SmsFlashPromotionLogDynaSqlProvider {
    /**
     * 查询限时购通知记录表(可根据条件查询)
     * @param smsFlashPromotionLog
     * @return
     */
    public String findSmsFlashPromotionLog(SmsFlashPromotionLog smsFlashPromotionLog){
        return new SQL(){
            {
                SELECT(" id,member_id,member_phone,product_name,subscribe_time,send_time ");
                FROM(" sms_flash_promotion ");
                StringBuffer sb=new StringBuffer();
                if(smsFlashPromotionLog!=null) {


                    if (smsFlashPromotionLog.getMemberId() != null) {
                        sb.append(" and  member_id=#{memberId}");
                    }
                    if (smsFlashPromotionLog.getMemberPhone() != null) {
                        sb.append(" and  member_phone=#{memberPhone}");
                    }
                    if (smsFlashPromotionLog.getProductName() != null) {
                        sb.append(" and  product_name=#{productName}");
                    }

                    if (smsFlashPromotionLog.getSubscribeTime() != null) {
                        sb.append(" and  subscribe_time=#{subscribeTime}");
                    }

                    if (smsFlashPromotionLog.getSendTime() != null) {
                        sb.append(" and  send_time=#{sendTime}");
                    }
                }
                WHERE(" 1=1 "+sb.toString());

            }
        }.toString();
    }
}
